- במפלס התחתון (בתחתית המדרגות) ובמפלס העליון (בראש המדרגות) יש מקום לכל הולכי הרגל

Size: px
Start display at page:

Download "- במפלס התחתון (בתחתית המדרגות) ובמפלס העליון (בראש המדרגות) יש מקום לכל הולכי הרגל"

Transcription

1 אוניברסיטת בן-גוריון מדור בחינות מספר נבחן: רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. בהצלחה! תאריך הבחינה: שם המורה: פרופ' מיכאל אלחדד ד"ר מני אדלר ד"ר אנדרי שרף שם הקורס: תכנות מערכות מספר הקורס: מיועד לתלמידי: מדעי המחשב, הנדסת תוכנה שנה: תשע"א סמסטר: א' מועד: א' משך הבחינה: שלש שעות חומר עזר: אסור 30) שאלה 1 נקודות) במקומות ציבוריים רבים (כמו לדוגמא, ברכבת התחתית המפורסמת של תל אביב) מותקנת מערכת של מדרגות נעות, לשם עליה וירידה בין מפלסים. בשאלה זו נעסוק בסימולציה של מנגנון זה. המערכת מורכבת מהאובייקטים הפסיביים הבאים:.(StairCase על כל מדרגה יש מקום להולך רגל אחד. StairCase) גרם מדרגות - במפלס התחתון (בתחתית המדרגות) ובמפלס העליון (בראש המדרגות) יש מקום לכל הולכי הרגל - שלו במרחב, כולל את הגובה הולך רגל המצב הפנימי של Pedestrian) ), קבוצה של הולכי רגל -.(Strategy ואסטרטגית התקדמות Strategy) הגובה של הולך הרגל, ניתן על ידי הגובה של המפלס התחתון ומספר המדרגות מהמפלס התחתון למקום בו הוא עומד. לדוגמא, אם גובה המפלס התחתון הוא 5, והולך הרגל נמצא 39 מדרגות מעל המפלס, נאמר כי גובהו הוא 44. אסטרטגיית ההתקדמות, קובעת את התנהגות הולך הרגל כאשר הוא נמצא בגרם מדרגות. המחזירה את הגובה החדש אליו next(),strategy עם מתודת ההתקדמות קיימים שלשה מימושים לממשק יגיע הולך הרגל: - הולך הרגל אינו עולה או יורד, אלא ממתין על המדרגה בה הוא עומד. Relaxed o - הולך הרגל מנסה להתקדם עצמאית מעלה HurryUp o - הולך הרגל מנסה להתקדם עצמאית מטה. HurryDown o בנוסף מוגדרים במערכת שני סוגים של אובייקטים אקטיביים: nt - Thread ('חוט') הרץ מעל המשימה המדרגות בקצב נתון. Movement - Thread ('חוט') הרץ מעל המשימה במורד גרם מדרגות בהתאם לאסטרטגית ההתקדמות שלו. StairCaseMovement Pedestrian edestrianmovement על גרם מדרגות: הנעה כלפי מעלה של גרם על הולך רגל: קידום הולך רגל במעלה או בסימולציה הנתונה, קיים גרם מדרגות אחד העולה מעלה, ושני הולכי רגל: הולך במפלס התחתון המנסה לעלות מעלה בנוסף להתקדמות המדרגות הנעות (אסטרטגיית - own הולך רגל במפלס העליון המנסה לרדת מטה נגד כיוון המדרגות הנעות (אסטרטגית - התבוננו בקטעי הקוד המממשים את המערכת וענו על השאלות שאחר כך:.(HurryUp.( HurryDown 1

2 2 interface Strategy { int next(int height); class Relaxed implements Strategy { public int next(int height) { return height; class HurryUp implements Strategy { public int next(int height) ) { return height+1; class HurryDown implements Strategy { public int next(int height) { return height-1; interface Pedestrian { int getheight(); void setheight(int int height); Strategy getstrategy(); void advance ance(staircase staircase); class Passenger implements Ped edestrian estrian { private int _height height; private final Strategy _strategy; Passenger (int height,, Strategy strategy) ) { _height = height; _strategy = strategy; public synchronized Strategy getstrategy() { return _strategy; _ public synchronized int getheight Height() { return _height _ height; ; public synchronized void setheight(int height) { _height = height; public void advance(staircase staircase) ) { //@TODO 2

3 3 interface StairCase { int fromheight Height(); int toheight Height(); Pedestria edestrian getpedestrian edestrian(int int i); i void setpedestrian edestrian(p (Pedestrian pedestrian,int i); int size(); int capacity(); class StairCaseImpl implements StairCase { private final Pedestrian edestrian[] _pedestrian edestrians; s; private final int _fromheight; private final int _toheight; StairCaseImpl(int int fromheight Height, int toheight Height) ) { _fromheight = fromheight; _to toheight = toheight; _pedestrian edestrians s = new PedestrianP edestrian[_toheight - _fromheight + 1] 1 ; public int fromheight () { return _fromheight _ fromheight; ; public int toheight () { return _toheight; public int capacity() { return _pedestrian edestrians. s.length length; public synchronized int size() { int size=0; for (Pedestrian p : _pedestrian edestrians) s) if (p!=null) size++; return size; public synchronized Pedestrian P getpedestrian edestrian(int int i) { return _pedestrian edestrians[i]; s[i]; public synchronized void setpedestrian edestrian(pedestrian p,, int i) i ) { _pedestrian edestrians[i [i] ] = p; class StairCaseMovementTask implements Runnable { 3

4 4 private final StairCase _staircase; private final long _speed; StairCaseMovementTask(StairCase staircase, long speed) { _staircase = staircase ; _speed = speed; public void run() { while (true) { try { for (int i=_staircase.capacity. capacity() ()-1; ; i>0; i--i --) ) { _staircase.setp setpedestrian edestrian(_staircase. _staircase.getp getpedestrian edestrian(i (i-1),i); Pedestrian p = _staircase.getp getpedestrian edestrian(i) i); if (p!=null) p.setheight(p..setheight(p.getheight()+1); getheight()+1); _staircase.setp setpedestrian edestrian(null,0); null,0); synchromized(_staircase staircase) ) { _staircase.notifyall(); Thread.sleep(_speed); catch (InterruptedException e) { class Pedestrian edestrianmovement MovementTask implements Runnable { private final Pedestrian _pedestrian edestrian; private final StairCase _staircase; private final long _speed; Pedestrian edestrianmovement MovementTask Task(Pedestrian pedestrian edestrian,, long speed,, StairCase staircase) ) { _pedestrian = pedestrian edestrian; ; _speed = speed; _staircase = staircase ; public void run() { while (true) { try { _pedestrian edestrian.advance(.advance(_staircase _staircase); Thread.sleep(_speed); catch (InterruptedException e) { return; class Simulation { public static void main(string[] args) { StairCase upstaircase = new StairCaseImpl(1, 39); Pedestrian pedestrian edestrian1 = new Passenger(1,new new HurryUp() ()); ); Pedestrian pedestrian edestrian2 = new Passenger(39 39,new HurryDown() ()); ); new Thread(new StairCaseMovementTask (upstaircase,1000 upstaircase,1000)).start(); 4

5 5 new Thread(new Pedestrian edestrianmovementtask (pedestrian edestrian1, , upstaircase)).start(); new Thread(new Pedestrian edestrianmovementtask (pedestrian edestrian2, , upstaircase)).start();,staircase וציינו (ונמקו) האם המחלקה א. הגדירו תכונה נשמרת (invariant) עבור הממשק (StairCase תחת כל חישוב מקבילי [10 נקודות] המממשת אותה בטוחה (במובן שמירה על האינווריאנטה של StairCaseImpl - Pedestrian בממשק advance() ב. הגדירו תנאי התחלה וסיום conditions) (pre/post עבור המתודה המקדמת את הולך הרגל בגרם המדרגות (הניתן כפרמטר) על פי האסטרטגיה שלו - וממשו את המתודה.Passenger במידה וקיים הולך רגל במדרגה הבאה, יש להמתין עד שהמקום יתפנה. [12 נקודות] במחלקה,StairCaseMovementTask ג. הראו כיצד ביטול הת'רד המבצע את.(deadlock) 8] נקודות] מביאה את הסימולציה למצב של ח בק class Simulation { public static void main(string[] args) { StairCase upstaircase = new StairCaseImpl(1, 39); Pedestrian pedestrian edestrian1 = new Passenger(1,new HurryUp()); ); Pedestrian ped edestrian estrian2 = new Passenger(39 39,new HurryDown()); new Thread(new StairCaseMovementTask (upstaircase,1000)).start(); new Thread(new Pedestrian edestrianmovementtask (pedestrian edestrian1, , upstaircase)).start(); new Thread(new Pedestrian edestrianmovementtask (pedestr edestrian ian2, , upstaircase)).start(); 30) שאלה 2 נקודות) משאלה.1 StairCaseImpl StairCase ו א. ממשו ב ++C את המחלקות ובביצוע השמה של ערך לאובייקט מסוג StairCaseImpl by של אובייקט מטיפוס value יש לתמוך בהעברה.(Java,StairCaseImpl שאינן קיימת ב במחלקה assignment operator ו copy constructor =) StairCase אין צורך לממש את הסנכרון. [18 נקודות] ב. ציירו את תמונת הזיכרון, כאשר מריצים את main ומגיעים למקום המסומן בתוך קוד המתודה [12 Q נקודות] void Q(const StairCase& staircase) { std::cout << "Mr. Memory, What t are the 39 steps?"; //@@ הזיכרון כאשר הרצת הקוד מגיעה לכאן תמונת לצייר את יש void main() { StairCaseImpl upstaircase(1, 39); StairCase* downstaircase = new StairCaseImpl Impl(1,39 (1,39); StairCaseImpl upstaircase2 = upstaircase; Q(upStairCase2); 5

6 6 30) שאלה 3 נקודות) בישיבת הנהלה של החברה המפעילה את המדרגות הנעות הוחלט, כי לשם בקרה על המערכת, הנעת גרם המדרגות - תתבצע בהפעלה מרחוק מתוך תהליך אחר המפעיל את כל StairCaseMovementTask כלומר ביצוע המשימה המדרגות הנעות של החברה, באתרים השונים. להלן קוד של התהליך המפעיל ממוקד הבקרה גרם מדרגות הנמצא באתר מרוחק. על מנת לקבל stub לגרם המדרגות המוגדר בזיכרון של התהליך המריץ את rmiregistry התהליך פונה ל Simulation בעמוד 4), ולאחר מכן מריץ על גרם מדרגות זה את המשימה הסימולציה בשאלה הראשונה (המחלקה.StairCaseMovementTask public class StairCaseControl { public static void main(string[] args) { try { StairCase upstaircase = (StairCase)Naming.lookup(" :4004/StairCase1"); new Thread(new StairCaseMovementTask (upstaircase,1000 upstaircase,1000)).start(); catch (Exception e) { e.printstacktrace(); א. ב. ג. ד. משאלה 1, כך שיתאימו למערכת החדשה. StairCaseImpl,StairCase ו,Simulation שנו את המחלקות [10 נקודות] הערה: התעלמו מיישום מחדש של מנגנון wait/notify במחלקות האחרות (כלומר, אין צורך לממש את notify בזיכרון של תהליך שני). התמקדו בשינוי האופי של בזיכרון של תהליך אחד ו wait האופן בו מבוצע.StairCase לאחר כמה פעולות תקשורת יתקדמו המדרגות הנעות מעלה בשלושה שלבים? (ניתן להניח כי תנאי ההתחלה תמיד מתקיימים). פרטו. [7 נקודות] StairCaseImpl.class האם הקובץ צריך להיות מוגדר במערכת הקבצים של המחשב בו רץ התהליך?StairCaseControl נמקו. [3 נקודות].Reactor,Stub מתבסס על תבנית ה עם ה StairCase של Skel נתון כי מימוש תקשורת ה ProtocolTask מסונכרנת. ocoltask כזכור, מתודת ה run() במחלקה סטודנט בקורס תכנות מערכות הציע, לשם ייעול, להוריד את הסנכרון של המתודה, ותחת זאת לסנכרן רק את הבלוק בחלק השני, כמתואר בקוד שלפניכם (השינויים שביצע הסטודנט מודגשים): class ProtocolTask implements Runnable { private final ServerProtocol l _protocol; private final StringMessageTokenizer _tokenizer; private final ConnectionHandler _handler; /* The fifo queue, which holds data coming from the socket. Access to the queue is serialized, to ensure correct *processing order - even if i f more data is received by the reactor while previous data is still being processed.*/ private final Vector<ByteBuffer> _buffers = new Vector<ByteBuffer>(); 6

7 7 public synchronized void run() { // first, add all the bytes we have to the tokenizer synchronized (_buffers) { while(_buffers.size() > 0) { ByteBuffer buf = _buffers.remove(0); this._tokenizer.addbytes(buf); // now, go over all complete messages and process them. synchronized (this) { while (_tokenizer.hasmessage()) { String msg = _tokenizer.nextmessage(); String response = this._protocol.processmessage(msg); if (response!= null) { try { ByteBuffer bytes = _tokenizer.getbytesformessage(response); this._handler.addoutdata(bytes); catch (CharacterCodingException e) { e.printstacktrace(); // This is invoked by the ConnectionHandler which runs in the reactor main thread. public void addbytes(bytebuffer b) { synchronized (_buffers) { _buffers.add(b); האם השינוי שהציע הסטודנט עשוי לפגום בפעילותן התקינה של המדרגות הנעות, בסימולציה הנתונה? נמקו תשובתכם. [10 נקודות] הנחיה: הבהירו לעצמכם אלו ת'רדים בשרת עובדים במקביל על חלקים שונים של המצב הפנימי ב,ProtocolTask ומתי זה קורה.,this איזה עיקרון בפרוטוקול זה בא להבטיח? על run() עימדו על הסיבה לסינכרון כל המתודה למעוניינים (זה לא בהכרח נדרש), ניתן למצוא בנספח (בסוף המבחן) את החלקים הרלבנטיים של ConnectionHandler המחלקה 7

8 8 10) שאלה 4 נקודות) לשם מעקב ובקרה אחר יעילות ההפעלה של המדרגות הנעות באתרים השונים, החליט זכיין הפעלה לשמור בבסיס נתונים, מידע סטטיסטי על המשתמשים במדרגות. עבור כל גרם מדרגות: מיקום גרם המדרגות (שם הארץ, שם העיר, שם המתחם) - אוריינטציה (עולה או יורד) - רשימה של הימים בהם הוא הופעל - תאריך o מספר עוברים ביום זה o זמן ממוצע למעבר ממפלס למפלס o א. ב. הגדירו מודל נתונים (טבלאות ומפתחות) עבור המערכת שתוארה לעיל. [5 נקודות] הגדירו שאילתת SQL המחזירה את כמות האנשים שעברה בכל אחד מגרמי המדרגות (שם המתחם ומספר העוברים) הממוקמים בב"ש, בתאריך 2/1/11, ממוין ע"פ מספר האנשים בסדר עולה. [5 נקודות] 8

9 9 ConnectionHandler נספח: המחלקה public class ConnectionHandler { protected final SocketChannel _schannel; protected final ReactorData _data; protected final AsyncServerProtocol _protocol; protected final StringMessageTokenizer _tokenizer; protected Vector<ByteBuffer> _outdata; protected final SelectionKey _skey; private ProtocolTask _task; // Post data in the pending data queue, so that the connectionhandler will send it through the socket. // switchtoreadwritemode() subscribes scribes this handler key to the OP_WRITE event // This event will immediately fire because the output buffer of the channel is empty. // It will keep firing as long as the output buffer is not filled. // When we are done sending pending data, we will unsubscribe from OP_WRITE. public synchronized void addoutdata(bytebuffer buf) { _outdata.add(buf); switchtoreadwritemode(); // Reads incoming data from the client:. Reads some bytes from the SocketChannel // Create a protocoltask, to process this data, possibly generating an answer. // Inserts the Task to the ThreadPool public void read() { // Do not read if protocol has terminated. Only write of pending data is // allowed when the protocol asked to close the connection. if (_protocol.shouldclose()) return; SocketAddress address = _schannel.socket().getremotesocketaddress(); logger.info("reading from " + address); ByteBuffer buf = ByteBuffer.allocate(BUFFER_SIZE); int numbytesread = 0; try { numbytesread = _schannel.read(buf); catch (IOException e) { numbytesread = -1; if (numbytesread == -1) { // Is the channel closed? // No more bytes can be read from the channel logger.info("client on " + address + " has disconnected"); closeconnection(); // tell the protocol that the connection terminated. _protocol.connectionterminated(); 9

10 10 return; // Add the buffer to the protocol task buf.flip(); _task.addbytes(buf); // Add the protocol task to the reactor which will parse and process the data // when a thread becomes available for it. _data.getexecutor().execute(_task); // Attempts to send data to the client. if all the data has been succesfully sent, the ConnectionHandler will // automatically switch to read only mode, otherwise it will stay in its current mode (which is read / write). public synchronized void write() { if (_outdata.size() == 0) { // if nothing left in the output string, go back to read mode switchtoreadonlymode(); return; // If there is something to send - send the first byte buffer // We will return to this write() operation very soon because the selector will keep firing the OP_WRITE event // after we are done writing this buffer and check if there are more buffers to be sent. ByteBuffer buf = _outdata.remove(0); if f (buf.remaining()!= 0) { _schannel.write(buf); // Check if the buffer contains more data: we could not send all of the buffer in one write // (the output buffer of the socket got full). So we remember that there is more data to be sent. // We will receive a new OP_WRITE event when the output buffer of the socket // is not full anymore and complete the write operation then. if (buf.remaining()!= 0) _outdata.add(0, buf); // Check if the protocol l asked us to close this connection. // If it did, we remain open as long as there are pending data to be sent. // As soon as all the data has been sent, we can close the connection. if (_protocol.shouldclose()) { switchtowriteonlymode(); if (buf.remaining() == 0) { logger.info("disconnecting client on " + _schannel.socket().getremotesocketaddress()); ); closeconnection(); 10

11 11 גיליון תשובות מספר נבחן: 30) שאלה 1 נקודות) סעיף א (10 0<=size()<=capacity()=to()-from()+1 מסונכרנת, והתוכנה הנשמרת לעייל תמיד מתקיימת final המחלקה בטוחה כי הגישה לשדות שאינם,setPedestrian() אינה פוגמת באינווריאנטה, כי יזרק fromheight בבנאי, והאינדקס i ב ו toheight אי בדיקת ערכי,_pedestrians ובגישה אליו). (ביצירת המערך Exception V 0<=i,j<capacity() <capacity(), i!= אם כוללים באינווריאנטה את האילוץ, שהולך רגל אינו מופיע בשתי מדרגות בו זמנית ) j getpedestrian ( התכונה לא מתקיימת בהכרח בקוד הנתון. etpedestrian(i)!= getpedestrian etpedestrian(j) תנאי התחלה: 5 נקודות בטיחות: 5 נקודות (12 נקודות) public synchronized void advance(staircase staircase) throws InterruptedException { staircase!= null && (staircase staircase.get.getpedestrian Pedestrian(getHeight() - staircase.fromheight fromheight()) == this getheight() staircase.fromheight fromheight() getheight() staircase.to toheight Height()) && staircase.get.getpedestrian Pedestrian(getStrateg getstrategy().next( y().next(getheight()) - staircase. fromheight()) == null //@POST: getheight() == = getstrategy().next(@pre(getheight()) && staircase.get.getpedestrian Pedestrian(@pre(getHeight() - staircase.fromheight fromheight()) == null && staircase.getpedestrian(getheight() - staircase.fromheight fromheight() ()) ) == this סעיף ב synchronized(staircase) { while (!(staircase!= null && staircase.getpedestrian(_strategy.next(getheight()) - staircase. fromheight()) == null && (_height == staircase.fromheight() s _height == staircase.toheight() staircase.getpedestrian(_height - staircase. fromheight()) == this))) staircase.wait(); staircase.setpedestrian(null, _height - staircase.fromheight()); _height = _strategy.next(_height); staircase.setpedestrian(this, _height - staircase.fromheight()); staircase.notifyall(); staircase wait this הערה: בפיתרון זה קיימת סכנת חבק, בשל תפישת המנעול על אותו). עם היציאה ל על (המשחררת רק 1

12 12 מפתח ניקוד: תנאי התחלה: 3 נקודות תנאי סיום: 2 נקודות מימוש: 7 נקודות בבדיקת המימוש הושם דגש על הנקודות הבאות - מנגנון המתנה המבוסס על wait/notify - שימוש במוניטור מתאים (staircase) - רצף סנכרון בין בדיקת תנאי התחלה ועד ביצוע הפעולה - חישוב נכון של האינדקס בגרם המדרגות ביחס לגובה הולך הרגל - עדכון גובה הולך הרגל - עדכון המדרגות סעיף ג (8 נקודות) חבק של המתנה הדדית עשוי להתרחש, בין שני הולכי רגל האחד עולה והשני יורד, הנפגשים בשתי מדרגות סמוכות. חבק זה המכונה בשפה המקצועית חמור ג ר ם משתחרר בנוכחות הת'רד המבצע את המשימה,StairCaseMovementTask המביאה את הולכי הרגל החבוקים למפלס פתוח. 30) שאלה 2 נקודות) class StairCase { public: virtual ~StairCase(); ~ virtual int fromheight() const = 0; virtual int toheight() const = 0; virtual Pedestrian *getpedestrian(int i) const = 0; virtual void setpedestrian(pedestrian *pedestrian,int i) = 0; virtual int size() const = 0; virtual int capacity() const = 0; סעיף א (18 נקודות) class StairCaseImpl : public StairCase { private: const Pedestrian **_pedestrians; const int _fromheight; const int _toheight; public: StairCaseImpl(int fromheight, int toheight) { 2

13 13 _fromheight = fromheight; _toheight = toheight; _size=0; _pedestrians = new Pedestrian*[_toHeight - _fromheight + 1] ; virtual ~StairCaseImpl(){ delete[] _pedestrians; StairCaseImpl(const StairCase& other){ _fromheight = other.fromheight fromheight() (); _toheight = other. toheight(); _pedestrians = new Pedestrian*[other.capacity()] ; for(int i=0; i other.capacity(); i++){ _pedestrians[i] = other. getpedestrian(i); StairCaseImpl & operator=(const StairCase& other) { _fromheight = other. fromheight(); _toheight = other. toheight(); Delete elete[] pedestrians _pedestrians; _pedestrians = new Pedestrian*[other.capacity()] ; for(int i=0; i other.capacity(); i++){ _pedestrians[i] = other. getpedestrian(i); int fromheight () const { return _fromheight; int toheight () ( const { return _toheight; int capacity() const { return _toheight - _fromheight + 1; int size() const { int size=0; for(int i=0; i<_toheight - _fromheight + 1; i++){ if (_pedestrians[i]!=null) size++; return size; Pedestrian* getpedestrian(int i) const { return _pedestrians[i]; void setpedestrian(pedestrian *p, int i) { 3

14 14 _pedestrians[i] = p; ; סעיף ב (12 נקודות) Stack address value meaning pointer to upstaircase return address from Q _toheight _fromheight pointer to _pedestrians in heap 1020 *vtable pointer to downstaircase in heap _toheight _fromheight pointer to _pedestrians in heap 1000 *vtable Heap address value meaning 7000 _pedestrians[39] _pedestrians array 6012 _pedestrians[39] _pedestrians array _toheight _fromheight 6000 *vtable 5000 _pedestrians[39] _pedestrians array 4

15 15 Grading Key 1. Missing inheritance, missing implementation of StairCase, StairCaseImpl, missing virtual methods C++ Syntax, Constructor (ctor), Destructor (dtor) [ ] 3. Definition, allocation and free of pedestrian array: Copy Constructor (copy ctor), Operator= Memory diagram a. each missing entry -3 b. missing vtable pointers -4 (no multiple deduction if missing inheritance above) c. functions, return address (r.a), parameters on stack -3, stack, heap confusions ) שאלה 3 נקודות) סעיף א (10 נקודות) What are the changes required to make StairCase are remote interface are the following (as documented in ): 1. On the StairCase interface: - Mark the interface remote by extending java.rmi.remote - Add java.rmi.remoteexception to all methods in the interface 2. On the StairCaseImpl implementation (the remote object): - Inherit from the java.rmi.server.unicastremoteobject - Add java.rmi.remoteexception to all methods of the class 3. In the process that publishes the remote object (the class Simulation), make the remote object available, by registering it in the rmiregistry: - Naming.rebind(" :4004/StairCase1", upstaircase); - In the specific case, it makes sense to add a method to the interface to indicate it is now under control of the remote controller that ensures the staircase movement but this was not expected as part of this answer. 4. Make sure all the parameters passed to and returned by remote methods are either: - Primitive types (int, char ) - Serializable types - Remote objects In our case, the parameters passed in the StairCase interface are: int and Pedestrian. So we had to make sure that class Pedestrian is Serializable. [Making this list was sufficient to get credit issue 4 was not taken into account in the grading, any missing indication of 1, 2 or 3 above caused a 3 point deduction] Most common errors: - Not listing the RemoteExceptions 5

16 16 - Marking that a class or an interface throws exception (I was shocked how many students wrote something that strange). A class does not throw an exception only methods do. - Confuse extends and implements (the remote interface extends java.rmi.remote, the remote object extends java.rmi.server.unicastremoteobject). - Forget about the Serializable condition on parameters (was not counted in the grading) In code: interface StairCase extends java.rmi.remote { int fromheight() throws java.rmi.remoteexception emoteexception; int toheight() throws java.rmi.remoteexception; Pedestrian getpedestrian edestrian(int i) throws java.rmi.remoteexception; void setpedestrian edestrian(p (Pedestrian pedestrian,int i) throws java.rmi.remoteexception; int size() throws java.rmi.remoteexception Exception; int capacity() throws java.rmi.remoteexception; class StairCaseImpl implements StairCase extends java.rmi.server.unicastremoteobject { private final Pedestrian P edestrian[] _pedestrian edestrians; s; private final int _fromheight; private final int _toheight; StairCaseImpl(int fromheight, int toheight) throws java.rmi.remoteexception { _fromheight = fromheight; _toheight = toheight; _pedestrian edestrians s = new PedestrianP edestrian[_toheight - _fromheight + 1] ; public int fromheight ()throws ( java.rmi.remoteexception { return _fromheight; public int toheight ()throws java.rmi.remoteexception { return _toheight; public int capacity()throws throws java.rmi.remoteexception { return _pedestrian edestrians.length; s.length; public synchronized int size() s throws java.rmi.remoteexception { int size=0; for (Pedestrian p : _pedestrian edestrians) s) if (p!=null) size++; return size; public synchronized Pedestrian P getpedestrian edestrian(int i) throws java.rmi.remoteexception { return _pedestrian edestrians[i]; s[i]; public synchronized void setpedestrian edestrian(p (Pedestrian p, int i) throws java.rmi.remoteexception { _pedestrian edestrians[i] s[i] = p; 6

17 17 class Simulation { public static void main(string[] args) { StairCase upstaircase = new StairCaseImpl(1, 39); Naming.rebind(" :4004/StairCase1", upstaircase); Pedestrian pedestrian edestrian1 = new Passenger(1,new HurryUp()); ); Pedestrian pedestrian edestrian2 = new Passenger(39,new HurryDown()); new Thread(new StairCaseMovementTask asemovementtask (upstaircase,1000)).start(); // Would make sense to wait until the remote staircase movement task is started not necessary new Thread(new Pedestrian edestrianmovementtask (pedestrian edestrian1,1000, 1000, upstaircase)).start(); new Thread(new Pedestrian destrianmovementtask (pedestrian edestrian2,1000, upstaircase)).start(); interface Pedestrian extends java.io.serializable { int getheight(); void setheight(int int height); Strategy getstrategy(); void advance(staircase staircase); סעיף ב (7 נקודות) How many communication operations are necessary to move up a staircase by 3 steps? We look at what the RMI client does: StairCase upstaircase=(staircase)naming.lookup(" :4004/staircase1 new Thread(new StairCaseMovementTask (upstaircase,1000)).start(); The Naming.lookup() call causes one round-trip communication with the rmiregistry server. The other part is of the process is that the remote object upstaircase is accessed through the run() method of StairCaseMovementTask. So we look at the code of run(): public void run() { while (true) { try { for (int i=_staircase.capacity. capacity() ()-1; ; i>0; i--i --) ) { _staircase.setpedestrian edestrian(_staircase. _staircase.getp getpedestrian edestrian(i (i-1),i); Pedestrian p = _staircase.getp getpedestrian edestrian(i) i); if (p!=null) p.setheight(p.getheight()+1); getheight()+1); 7

18 18 _staircase.setp setpedestrian edestrian(null,0); null,0); synchromized(_staircase staircase) ) { _staircase.notifyall(); Thread.sleep(_speed); catch (InterruptedException e) { In this code, _staircase is bound to a remote object (that is, it is a stub that sends remote calls to the remote object). This means each call on _staircase is a remote call and we want to call such remote calls each call is a round-trip communication operation. The calls are: For each iteration in the while(true) loop: In the for loop (capacity() times): getpedestrian() setpedestrian() setpedestrian(null) [We can either ignore the notifyall() call as indicated in the question or count it as a remote variant] Total: (capacity() * 2 + 1) calls per iteration. Each iteration moves the stair by 1 step up. We want to count 3 steps up: 3 * (capacity() * 2 + 1) + 1 (lookup) We know that capacity() is 39 in our case giving: 3 * (39 * 2 + 1) + 1 = 238 round trip operations. Possible variation: - Some students assumed that the Pedestrian interface is a remote interface instead of being a serializable interface. This is fine and in this case, p.setheight() and p.getheight() must be counted as 2 round-trip calls in the loop. Most common errors: - Not counting the operations at all (detail which operations are remote calls). - Giving a random number as an answer. - Not taking into account the loop over the capacity(). - Not taking into account the loop for 3 steps - Not counting the lookup() operation [Either loops omission was counted as 2 point deduction] סעיף ג (3 נקודות) Must the class StairCaseImpl.class be present in the file system side of the process running StairCaseControl? 8

19 19 No it does not since this is a remote object, which is accessed through the remote interface StairCase. When StairCaseControl executes: StairCase upstaircase=(staircase)naming.lookup(" :4004/staircase1 It gets in return an instance of the stub class (StairCaseStub.class) which implements the StairCase interface. It never accesses the staircaseimpl code, which is only operated on the side of the Simulation process. סעיף ד (10 נקודות) Assume the implementation of the skel uses the Reactor pattern. A student proposes to remove the synchronized directive on the run() method of ProtocolTask, and instead to limit it half of the method (dealing with the tokenizer and protocol and not with the part dealing with the buffers and tokenizer). - Does the change affect correctness? - What is the condition that the synchronized run() enforces? First why is run() synchronized? Notes from the reactor pattern: - A protocoltask instance is associated to a single connectionhandler. That means, a protocoltask will only operate on the same client connection. There is only one protocoltask per connectionhandler. - The protocoltask is submitted to the thread pool executor each time new data is read by the connectionhandler (in the read() method). When run() is synchronized, we know that the calls to run() from the executor will be serialized (executed sequentially one after the other) so that 2 threads from the thread pool cannot execute the same task simultaneously. If we remove the synchronized directive from run(), then there can be the following situation: - ConnectionHandler receives a read event from the reactor and posts its task to the thread pool for execution. - Thread T1 from the thread pool starts running the task. - Another read event arrives from the reactor to the ConnectionHandler and the same task is posted again to the thread pool for execution. - Thread T2 from the thread pool starts running the same task while T1 is still working on the same task. Can this fact cause correctness problems? - If the 2 read events come from 2 separate messages m1 and m2 sent from the same client, then this could potentially lead to a situation where the server processes m2 before m1 and it does not respect the order of messages sent by the client. - If the 2 read events come from 2 fragments of the same message m1, or from fragments that overlap 2 distinct messages m1 and m2, then potentially, this situation could lead to a situation where the bytes are added to the tokenizer in the wrong order. 9

20 20 Note that the other way to access the protocol task is through the method addbytes() which is invoked by the ConnectionHandler (in the reactor thread), when it receives data in the read() event. But note that addbytes() is NOT synchronized and this is on purpose. The buffers queue serves as a buffer between the reactor thread (producer) and the thread running the protocoltask (consumer). Between these 2 active objects, only the buffers object needs to be synchronized, and it is properly synchronized in all places where buffers is accessed. Now we need to look at the details because the proposed code does not completely remove the synchronization it moves it from one place to another (smaller scope). So can we really get the risks highlighted above? With the synchronization proposed by the student, we have 2 sections the sync(buffers) part, and the sync(this) part. So we can now get the situation with 2 threads active on the same ProtocolTask instance: - T1 is inside part1 (moves buffers from buffers to tokenizer) - T2 is inside part2 (moves messages from tokenizer to protocol, execute protocol and pass return data to connectionhandler). But we cannot have a situation where T1 and T2 are together in part1 or together in part2. Risk 1: (protocol processes m2 before m1) cannot happen because the messages are inserted in order from buffers to tokenizer: only the reactor thread adds to buffers so buffers is always ordered, and whether T1 or T2 read from buffers, they always push to the same tokenizer so tokenizer gets data in the proper order. Since only one thread can read complete messages from tokenizer at a time, and the sequence read message / execute message is synchronized, there is no risk of message order inversion. Risk 2: (buffers with partial messages are pushed into tokenizer in the wrong order) cannot happen because buffers are pushed into tokenizer by one thread at a time and the sequence buffers.remove() / tokenizer.add() is synchronized. Note that the only element that is shared between part1 and part2 is the tokenizer and we must make sure that tokenizer is properly fully synchronized. In the reactor code, this is indeed the case. All in all the changes proposed by the student are safe. Note: we do not discuss here whether the changes are beneficial or not to the reactor. They could increase parallelism but they could also reduce scalability it depends on the pattern of communication between clients and server (many fragmented messages, several messages sent in sequence by the client without getting a response from the server). This is out of the scope of the question. Grading considered: - Any mention of message ordering got a credit of 5 points or more. - Any mention of partial messages ordering got a credit of 3 points or more. - Any mention that tokenizer must be fully synchronized got a credit of 5 points or more. - Explanation that lack of synchronization brings risk is not sufficient we expected specific explanation of the risks. 10

21 21 - Explanation that there is only one client for this server were wrong. The risks exist even with a single client. 30) שאלה 4 נקודות) סעיף א (5 נקודות) Data Model: create table Location ( LocationId int primary key, LocationName varchar(200), City varchar(200), Country varchar(100)) create table Staircase ( StaircaseId int Primary Key, LocationId int Foreign Key references Location, Orientation int // 1 = ascending, 2 = descending ) create table StaircaseOperation ( StaircaseId int Foreign Key references Staircase, OperationDay datetime, PassengersNumber int, AverageTripDuration int, // average duration in milliseconds Primary Key (StaircaseId, OperationDay) ) Common Errors: - Types of fields must be specified (int, varchar, date, Boolean) [1 point] - Primary Keys must be specified for each table [2 to 3 points] - Primary Keys must be unique for each table [OperationDay alone in StaircaseOperation is not unique, it cannot be PK] - Foreign Keys must be specified [2 to 3 points] - When there is a relation 1-n from T1 to T2, then the foreign key is in table T2. In our example, the relation Staircase to StaircaseOperations is 1-n (there is one row of Operations for each date for each staircase). Therefore, the foreign key (StaircaseId) is in the table StaircaseOperations (and not the opposite a date field in the Staircase table). - Tables must be normalized [Was not penalized] - If there is a group of fields that are repeated in many rows, normalization consists of replacing these fields with a foreign key to a table where the group of fields are stored. For example, since LocationName, City and Country could possibly be repeated many times for each staircase in each location in the same city, we defined the table Location to normalize the schema. 11

22 22 סעיף ב (5 נקודות) Select Staircase.StaircaseId, Location.LocationName, StaircaseOperation.PassengersNumber From ((Staircase inner join Location on Staircase.locationId = Location.LocationId) inner join staircaseoperation on staircase.staircaseid = staircaseoperation.staircaseid) Where Location.city = 'Beer Sheva' and StaircaseOperation.OperationDay = ' ' Order by StaircaseOperation.PassengersNumber asc 12

SPL - PS12. Reactor and Java New-IO (nio) classes

SPL - PS12. Reactor and Java New-IO (nio) classes SPL - PS12 Reactor and Java New-IO (nio) classes Multi-Threaded server, as seen in Tirgul 11 - one thread is in charge of accepting new connections - opens a new thread for each new client. - Thus, handling

More information

גיליון תשובות מספר נבחן:

גיליון תשובות מספר נבחן: גיליון תשובות מספר נבחן: 03( שאלה 1 סעיף א )02 (i) //@PRE: checkinv(other.getx(),other.gety(),other.getradius()) //@POST: getradius() other.getradius() >= // Math.max(Math.abs(getY()-other.getY()),Math.abs(getX()-

More information

גיליון תשובות מספר נבחן: סעיף ג (10 נקודות) הגדרת בטיחות הינה שמירה על האינווריאנטה של האובייקטים במהלך ההרצה.

גיליון תשובות מספר נבחן: סעיף ג (10 נקודות) הגדרת בטיחות הינה שמירה על האינווריאנטה של האובייקטים במהלך ההרצה. גיליון תשובות מספר נבחן: (30 נקודות) שאלה 1 סעיף א (15 נקודות) remove() המתודה remove() גם משנה את מצב האובייקט,(command) וגם מחזירה ערך.(query) על פי עקרונות העיצוב שלמדנו בכיתה יש להפריד שאילתות מפקודות.

More information

אוניברסיטת בן-גוריון מדור בחינות רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. בהצלחה! מספר נבחן:

אוניברסיטת בן-גוריון מדור בחינות רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. בהצלחה! מספר נבחן: אוניברסיטת בן-גוריון מדור בחינות מספר נבחן: רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. בהצלחה! תאריך הבחינה: 13.2.2012 שם המורה: פרופ' מיכאל אלחדד ד"ר מני אדלר ד"ר אנדרי שרף שם הקורס:

More information

מבוא למדעי המחשב תרגול 8 רשימה משורשרת כללית, Comparator

מבוא למדעי המחשב תרגול 8 רשימה משורשרת כללית, Comparator מבוא למדעי המחשב 2017 תרגול 8 רשימה משורשרת כללית, Comparator בתרגול היום. LinkedList בניית ההכללה מ- LinkIntList תרגול המבנה ושימושיו ממשקים: Comparator Sorted Linked List ל- LinkedList ע"י שימוש ב- Comparator

More information

מצליחה. 1. int fork-bomb() 2. { 3. fork(); 4. fork() && fork() fork(); 5. fork(); printf("bla\n"); 8. return 0; 9. }

מצליחה. 1. int fork-bomb() 2. { 3. fork(); 4. fork() && fork() fork(); 5. fork(); printf(bla\n); 8. return 0; 9. } שאלה : (4 נקודות) א. ב. ג. (5 נקודות) הגדירו את המונח race-condition במדוייק לא להשמיט פרטים. ספקו דוגמא. (5 נקודות) מהו? Monitor נא לספק הגדרה מלאה. ( נקודות) ( נקודות) ציינו כמה תהליכים יווצרו בקוד הבא

More information

בשאלה זו נמשיך לעסוק במערכת לטיהור המים בה עסקנו במועד א'. המערכת מורכבת, כזכור, מהאובייקטים הפסיביים הבאים:.Pool. .Purifier בממשק מוגדרת המתודה

בשאלה זו נמשיך לעסוק במערכת לטיהור המים בה עסקנו במועד א'. המערכת מורכבת, כזכור, מהאובייקטים הפסיביים הבאים:.Pool. .Purifier בממשק מוגדרת המתודה אוניברסיטת בן-גוריון מדור בחינות מספר נבחן: רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו בהצלחה! תאריך הבחינה: 2222010 שם המורה: ד"ר מיכאל אלחדד ד"ר מני אדלר מר אוריאל ברגיג שם הקורס:

More information

תוכנה 1 סמסטר א' תשע"א

תוכנה 1 סמסטר א' תשעא General Tips on Programming תוכנה 1 סמסטר א' תשע"א תרגול מס' 6 מנשקים, דיאגרמות וביטים * רובי בוים ומתי שמרת Write your code modularly top-down approach Compile + test functionality on the fly Start with

More information

אוניברסיטת בן-גוריון מדור בחינות רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. שימו לב: על תשובות ריקות יינתן 20% מהניקוד! בהצלחה!

אוניברסיטת בן-גוריון מדור בחינות רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. שימו לב: על תשובות ריקות יינתן 20% מהניקוד! בהצלחה! אוניברסיטת בן-גוריון מדור בחינות מספר נבחן: רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. שימו לב: על תשובות ריקות יינתן 20% מהניקוד! בהצלחה! תאריך הבחינה: 09.02.2015 שם המורה: ד"ר

More information

גיליון תשובות מספר נבחן:

גיליון תשובות מספר נבחן: גיליון תשובות מספר נבחן: 30( שאלה 1 נקודות( א. ב. התכונה הנשמרת מתייחסת אך ורק למיקום המכוניות בצומת, כלומר למיקום המכוניות בשדה _cars הגישה לשדה זה מסונכרנת, אך מצד שני אין בדיקה של מיקום המכונית טרם

More information

ב ה צ ל ח ה! אוניברסיטת בן גוריון בנגב מספר נבחן : תאריך המבחן: כ"ה תשרי תשע"ח 15/10/17 שמות המורים: ציון סיקסיק מיועד לתלמידי : א'

ב ה צ ל ח ה! אוניברסיטת בן גוריון בנגב מספר נבחן : תאריך המבחן: כה תשרי תשעח 15/10/17 שמות המורים: ציון סיקסיק מיועד לתלמידי : א' אוניברסיטת בן גוריון בנגב מספר נבחן : תאריך המבחן: כ"ה תשרי תשע"ח 15/10/17 שמות המורים: ציון סיקסיק א' ב- C תכנות מבחן ב: 202-1-9011 מס' הקורס : הנדסה מיועד לתלמידי : א' מועד קיץ סמ' שנה תשע"ז 3 שעות משך

More information

<exp> ::= <define> <cexp> <define> ::= ( define <var-decl> <cexp> ) / DefExp(var:VarDecl, val:cexp)

<exp> ::= <define> <cexp> <define> ::= ( define <var-decl> <cexp> ) / DefExp(var:VarDecl, val:cexp) הנחיות כלליות: תאריך הבוחן: 10.5.2018 שם המרצה: מני אדלר,מיכאל אלחדד, ירון גונן מבחן בקורס: עקרונות שפות תכנות מס' קורס: 202-1-2051 מיועד לתלמידי: מדעי המחשב והנדסת תוכנה שנה: ב' סמסטר: ב' משך הבוחן: 2

More information

גיליון תשובות על תשובות ריקות יינתן 20% מהניקוד!

גיליון תשובות על תשובות ריקות יינתן 20% מהניקוד! גיליון תשובות על תשובות ריקות יינתן 20% מהניקוד! מספר נבחן: 30( שאלה 1 סעיף א )7 שני ת'רדים המפעילים את מתודת ה move על אחד משני גלגלים סמוכים מסוג SimpleGear הת'רד הראשון תופס את הגלגל הראשון this( שלו(,

More information

שאלה 1, סעיף ב )11 נק'(

שאלה 1, סעיף ב )11 נק'( שאלה 1, סעיף א )8 נק'( public static boolean lexlt(string s1, String s2) for (int i=0; i

More information

אוניברסיטת בן-גוריון מדור בחינות רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. בהצלחה! מספר נבחן:

אוניברסיטת בן-גוריון מדור בחינות רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. בהצלחה! מספר נבחן: אוניברסיטת בן-גוריון מדור בחינות מספר נבחן: רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. בהצלחה! תאריך הבחינה: 5.3.0010 שם המורה: פרופ' מיכאל אלחדד ד"ר מני אדלר ד"ר אנדרי שרף שם הקורס:

More information

אוניברסיטת בן-גוריון בהצלחה! מספר נבחן: מדור בחינות רשמו תשובותיכם בשאלון זה בלבד ובמקום המוקצה לכך בלבד! תשובות מחוץ לשאלון לא יבדקו.

אוניברסיטת בן-גוריון בהצלחה! מספר נבחן: מדור בחינות רשמו תשובותיכם בשאלון זה בלבד ובמקום המוקצה לכך בלבד! תשובות מחוץ לשאלון לא יבדקו. אוניברסיטת בןגוריון מדור בחינות מספר נבחן: רשמו תשובותיכם בשאלון זה בלבד ובמקום המוקצה לכך בלבד! תשובות מחוץ לשאלון לא יבדקו. תאריך הבחינה: 13.7.2008 שם המורה: ד"ר מיכאל אלחדד ניר צחר אוריאל ברגיג שם הקורס:

More information

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes תוכנה 1 תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes class Outer { static class NestedButNotInner {... class Inner {... מחלקות מקוננות NESTED CLASSES 2 מחלקה מקוננת Class) )Nested

More information

ד"ר אחיה אליסף מר בני לוטטי פרופ' אנדרי שרף הנדסת תוכנה

דר אחיה אליסף מר בני לוטטי פרופ' אנדרי שרף הנדסת תוכנה אוניברסיטת בן-גוריון מדור בחינות מספר נבחן: רשמו תשובותיכם בגיליון התשובות בלבד, תשובות מחוץ לגיליון לא יבדקו. שימו לב: על תשובות ריקות יינתן 20% מהניקוד! בהצלחה! תאריך הבחינה : 13.2.2017 שם המורה : ד"ר

More information

מבוא לתכנות ב- JAVA תרגול 7

מבוא לתכנות ב- JAVA תרגול 7 מבוא לתכנות ב- JAVA תרגול 7 רקורסיה - הקדמה הגדרה רקורסיבית: חדר הוא מסודר אם צד שמאל שלו מסודר שלו מסודר. וצד ימין שיטת פתרון רקורסיבית: פתרון מופעים פשוטים יותר של בעיה בכדי לפתור את הבעיה המקורית רקורסיה

More information

מדעי המחשב 2 יחידות לימוד פתרון בחינת הבגרות פרק א. I x > a. פתרון 2: משפט switch

מדעי המחשב 2 יחידות לימוד פתרון בחינת הבגרות פרק א. I x > a. פתרון 2: משפט switch 1 מדעי המחשב 2 יחידות לימוד פתרון בחינת הבגרות שאלה פרק א :1 m a b k k b x I x > a II x < b פלט I && II 0 8 12 8 4 1 9 11 2 10 11 9 8 2 12 35 13 העמודות המסומנות בכחול אינן עמודות חובה בפתרון. שאלה 2:

More information

מערכים שעור מס. 4 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1

מערכים שעור מס. 4 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 מערכים שעור מס. 4 דרור טובי דר' כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 למה מערכים? ברצוננו לאחסן בתוכנית ציוני בחינה כדי לחשב את ממוצע הציונים וסטיית התקן. נניח ש 30 סטודנטים לקחו

More information

גיליון תשובות מספר נבחן:

גיליון תשובות מספר נבחן: גיליון תשובות מספר נבחן: 03( שאלה 1 סעיף א )11 - כפי שנלמד בהרצאות, התכונה נשמרת ותנאי התחלה וסיום מוגדרים על הממשק, ולא על מימוש ספציפי. ההגדרה צריכה להתבסס על שאילתות בסיס. במידה והשאילתות בממשק אינן

More information

תכנות מונחה עצמים משחקים תשע"ו

תכנות מונחה עצמים משחקים תשעו move semantics 1 תכנות מונחה עצמים ופיתוח משחקים תשע"ו סמנטיקת ההעברה semantics( )Move move semantics 2 מטרה האצה של התוכניות, שיפור בביצועים על ידי חסכון בבנייה והעתקה של אובייקטים זמניים move semantics

More information

גיליון תשובות מספר נבחן:

גיליון תשובות מספר נבחן: גיליון תשובות מספר נבחן: 30) שאלה 1 ראשית, מספר הערות על מאפייני משחק הקלפים (מטאפורה ש חוּ קה על החיים, הקורס, והמבחן) אשר פורטו בשאלה זו: משחק מרתק המשלב הנאה. ראו מקרה הרב יהודה-אריה מודנה, מגדולי המלומדים

More information

משתנים שעור מס. 2 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1

משתנים שעור מס. 2 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 משתנים שעור מס. 2 דרור טובי דר' כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 תפקיד המשתנים הצהרה על משתנה השמת ערך במשתנה int a, b, c; a = 1234; b = 99; c = a + b; משתנים מאפשרים לנו לשמור

More information

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions מבוא לתיכנות עם MATLAB 234127 Lecture 5: Boolean logic and Boolean expressions Written by Prof. Reuven Bar-Yehuda, Technion 2013 Based on slides of Dr. Eran Eden, Weizmann 2008 1 >>g = [89 91 80 98]; >>p

More information

תוכנה 1 בשפת Java נושאים שונים בהורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב

תוכנה 1 בשפת Java נושאים שונים בהורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב תוכנה 1 בשפת Java נושאים שונים בהורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב Today Static vs. Dynamic binding Equals / hashcode String Immutability (maybe) 2 Static versus run-time

More information

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions מבוא לתיכנות עם MATLAB 23427 Lecture 5: Boolean logic and Boolean expressions Written by Prof. Reuven Bar-Yehuda, Technion 203 Based on slides of Dr. Eran Eden, Weizmann 2008 ביטויים לוגיים דוגמא: תקינות

More information

3 Dynamic Routing A (RIP and OSPF)

3 Dynamic Routing A (RIP and OSPF) אוניברסיטת בן גוריון בנגב המחלקה להנדסת מערכות תקשורת רשתות תקשורת מחשבים - 2 קורס 37110211 מעבדה בתקשורת מחשבים 3 Dynamic Routing A (RIP and OSPF) בשבוע (29/11/2011) 5 בשבוע (13/12/2011) 7 מעבדה מספר

More information

Algorithms. Intro2CS week 5

Algorithms. Intro2CS week 5 Algorithms Intro2CS week 5 1 Computational problems A computational problem specifies an inputoutput relationship What does the input look like? What should the output be for each input? Example: Input:

More information

הנכות 1 םוכיס לוגרת 14 1

הנכות 1 םוכיס לוגרת 14 1 תוכנה 1 סיכום תרגול 14 1 קצת על מנשקים מנשק יכול להרחיב יותר ממנשק אחד שירותים במנשק הם תמיד מופשטים וציבוריים public interface MyInterface { public abstract int foo1(int i); int foo2(int i); The modifiers

More information

תרשים המחלקות ותרשים העצמים

תרשים המחלקות ותרשים העצמים 1 תרשים המחלקות ותרשים העצמים חלק שלישי: ניתוח ועיצוב מערכות מידע באמצעות שימוש ב- UML ומתודולוגיית ה- Process )UP( Unified E1 3 E2 2 Outline UML Introduction Class Diagram Class Association Self association

More information

רשימות דילוגים Skip Lists

רשימות דילוגים Skip Lists Lecture6 of Geiger & Itai s slide brochure www.cs.technion.ac.il/~dang/courseds רשימות דילוגים Skip Lists Skip lists: A probabilistic Alternative to Balanced Trees, William Pugh, Communications of the

More information

Amortized Analysis, Union-Find,

Amortized Analysis, Union-Find, Practical Session No. 13 Amortized Analysis, Union-Find, AMORTIZED ANALYSIS Refers to finding the average running time per operation, over a worst-case sequence of operations. Amortized analysis differs

More information

הערה על הפתרון: בתנאי הקדם אין לבדוק שהמשחק לא השתנה. המתודה מוגדרת היטב ויש לה ערך החזרה למקרה זה.

הערה על הפתרון: בתנאי הקדם אין לבדוק שהמשחק לא השתנה. המתודה מוגדרת היטב ויש לה ערך החזרה למקרה זה. אוניברסיטת בן-גוריון מדור בחינות מספר נבחן: רשמו תשובותיכם בגיליון התשובות בלבד, תשובות מחוץ לגיליון לא יבדקו. שימו לב: על תשובות ריקות יינתן 20% מהניקוד. בהצלחה! תאריך הבחינה : 6.3.2017 שם המורה : ד"ר

More information

אוניברסיטת בן-גוריון מדור בחינות רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. שימו לב: על תשובות ריקות יינתן 02% מהניקוד! בהצלחה!

אוניברסיטת בן-גוריון מדור בחינות רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. שימו לב: על תשובות ריקות יינתן 02% מהניקוד! בהצלחה! אוניברסיטת בן-גוריון מדור בחינות מספר נבחן: רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. שימו לב: על תשובות ריקות יינתן 02% מהניקוד! בהצלחה! תאריך הבחינה: 213...4 שם המורה: ד"ר אנדרי

More information

תוכנה 1 תרגול 2: מערכים, מבני בקרה ושגיאות

תוכנה 1 תרגול 2: מערכים, מבני בקרה ושגיאות תוכנה 1 תרגול 2: מערכים, מבני בקרה ושגיאות מערכים Array: A fixed-length data structure for storing multiple values of the same type Example: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5

More information

תזכורת: עץבינארי מבוא למדעי המחשב הרצאה 24: עצי חיפוש בינאריים

תזכורת: עץבינארי מבוא למדעי המחשב הרצאה 24: עצי חיפוש בינאריים מבוא למדעי המחשב הרצאה 2: עצי חיפוש בינאריים תזכורת: עץבינארי בנוסףלרשימהמקושרת ומערך, הצגנומבנהנתונים קונקרטיחדש עץבינארי עץבינארימורכבמ: שורש תת-עץשמאלי תת-עץימני A B C D E F G 2 תזכורת: שורש ותתי-עצים

More information

מבוא לתכנות מערכות מבחן מועד א' סמסטר חורף

מבוא לתכנות מערכות מבחן מועד א' סמסטר חורף הפקולטה למדעי המחשב פרופ' גיל ברקת נועם שגב, שרי דואק, רן ברואר, דור כהן הטכניון מכון טכנולוגי לישראל 70.70.07.4 מבוא לתכנות מערכות 024.00 מבחן מועד א' סמסטר חורף 07.207.4 הוראות כלליות משך המבחן: 081

More information

הנכות 1 םוכיס לוגרת 13 1

הנכות 1 םוכיס לוגרת 13 1 תוכנה 1 סיכום תרגול 13 1 בחינה באופק! הבחינה תכלול את כל הנושאים שכיסינו במהלך הסמסטר: כל ההרצאות כל תרגולים כל תרגילי בית חומר סגור שאלות אמריקאיות 2 קצת על מנשקים מנשק יכול להרחיב שירותים במנשק הם תמיד

More information

תרגול 4 פונקציות. מבנה של פונקציה: public static <return value type> <function name> (<arg1 type> <arg1>, <arg2 type> <arg2>, ) { <function body> }

תרגול 4 פונקציות. מבנה של פונקציה: public static <return value type> <function name> (<arg1 type> <arg1>, <arg2 type> <arg2>, ) { <function body> } נושאי התרגול: מה הן פונקציות הגדרת פונקציה,קריאה לפונקציה העברת ארגומנטים,החזרת ערך או void העברת משתנים פרימיטיביים ומערכים לפונקציה העמסה של פונקציות תרגול 4 פונקציות מוטיבציה לעיתים,אנו נזקקים לבצע

More information

תור שימושים בעולם התוכנה

תור שימושים בעולם התוכנה מבוא למדעי המחשב הרצאה : Queue, Iterator & Iterable תור מבנה נתונים אבסטרקטי תור שימושים בעולם התוכנה השימושים של תורים בעולם התוכנה מזכירים מאוד תורים במציאות: )VoIP( )YouTube( מקלדת שידור סרט באינטרנט

More information

else if (p.getinfo().getvotes() < c1.getvotes()) { c1 = p.getinfo()

else if (p.getinfo().getvotes() < c1.getvotes()) { c1 = p.getinfo() class BigBrother רשימה מועמדים לתחרות // candidates; private List publc void MakeVote(String name) הפעולה מקבלת שם, מוצאת את המתמודד ומוסיף לו הצבעה אחת // Node p = candidates.getfirst();

More information

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Loop through Arrays. Array Creation and Initialization

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Loop through Arrays. Array Creation and Initialization מערכים תוכנה 1 Array: A fixed-length data structure for storing multiple values of the same type Example from last week: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5 6 7 תרגול 2: מערכים

More information

כתבו קוד ב- 3 קבצי ה hpp (כתבו כהערה את שם הקובץ מעל) כך שהקוד יהיה תקין ובסגנון טוב. אין חובה

כתבו קוד ב- 3 קבצי ה hpp (כתבו כהערה את שם הקובץ מעל) כך שהקוד יהיה תקין ובסגנון טוב. אין חובה פקולטה: מדעי הטבע מחלקה: מדעי המחשב שם הקורס: מבנה זכרון ושפת ++C קוד הקורס: 7027810 תאריך בחינה: שאלות לדוגמא משך הבחינה: שעתיים שם המרצים: ד"ר אופיר פלא, ד"ר מירי בן ניסן חומר עזר: פתוח שימוש במחשבון:

More information

הנכות 1 םוכיס לוגרת 13 1

הנכות 1 םוכיס לוגרת 13 1 תוכנה 1 סיכום תרגול 13 1 קצת על מנשקים מנשק יכול להרחיב יותר ממנשק אחד שירותים במנשק הם תמיד מופשטים וציבוריים public interface MyInterface { public abstract int foo1(int i); int foo2(int i); The modifiers

More information

Communication Networks ( ) / Spring 2011 The Blavatnik School of Computer Science, Tel-Aviv University. Allon Wagner

Communication Networks ( ) / Spring 2011 The Blavatnik School of Computer Science, Tel-Aviv University. Allon Wagner Communication Networks (0368-3030) / Spring 2011 The Blavatnik School of Computer Science, Tel-Aviv University Allon Wagner Kurose & Ross, Chapter 3.5.5, 3.7 (5 th ed.) Many slides adapted from: J. Kurose

More information

שים לב! אין לכתוב בשוליים. השוליים יחתכו לצורך סריקת המבחן.

שים לב! אין לכתוב בשוליים. השוליים יחתכו לצורך סריקת המבחן. מספר : 804042 שם המרצה: תאריך הבחינה: ד"ר גדעון גרדוול, ד"ר אריאלה ריכרדסון 13/02/2013 משך הבחינה )בדקות(: 150 חומר עזר מותר לשימוש: ללא חומר עזר מחשבון: ללא מחשבון מס' תלמיד: מכון: לב/נוה, טל, טל-דעת,

More information

רזח יליגרתו םי יראני ב ם

רזח יליגרתו םי יראני ב ם מבוא למדעי המחשב עצים בינאריים ותרגילי חזרה תרגול 13: עצים בינאריים - הגדרה הגדרה: עץ בינארי הוא עץ ריק )בלי צמתים( או עץ המורכב משורש ושני תתי-עצים, הוא עץ בינארי. ימני ושמאלי, שכל אחד מהם שאלה עץ בינארי

More information

תוכנה 1 תרגול מספר 13

תוכנה 1 תרגול מספר 13 1 תוכנה 1 תרגול מספר 13 ו- HashCode Equals עוד על טיפוסים מוכללים )Advanced Generics( חריגים )Exceptions( בית הספר למדעי המחשב אוניברסיטת תל אביב 1 2 ו- HASHCODE EQUALS 3 תזכורת: המחלקה Object package

More information

תוכנה 1 תרגול מספר 13

תוכנה 1 תרגול מספר 13 1 2 תוכנה 1 תרגול מספר 13 ו- HashCode Equals עוד על טיפוסים מוכללים )Advanced Generics( ו- HASHCODE EQUALS חריגים )Exceptions( בית הספר למדעי המחשב אוניברסיטת תל אביב 1 3 4 package java.lang; תזכורת: המחלקה

More information

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Array Creation and Initialization. Loop through Arrays

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Array Creation and Initialization. Loop through Arrays מערכים Array: A fixed-length data structure for storing multiple values of the same type תוכנה 1 Example: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5 6 7 odds: 1 3 5 7 9 11 13 15 odds.length

More information

תוכנה 1 3 תרגול מס' מערכים ומבני בקרה

תוכנה 1 3 תרגול מס' מערכים ומבני בקרה תוכנה 1 3 תרגול מס' מערכים ומבני בקרה מערכים Array: A fixed-length data structure for storing multiple values of the same type Example: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5 6 7 odds:

More information

Practical Session - Heap

Practical Session - Heap Practical Session - Heap Heap Heap Maximum-Heap Minimum-Heap Heap-Array A binary heap can be considered as a complete binary tree, (the last level is full from the left to a certain point). For each node

More information

הנכות 1 תואיגש םע תודדומתהו תואלול,םיכרעמ : לו 2 גרת

הנכות 1 תואיגש םע תודדומתהו תואלול,םיכרעמ : לו 2 גרת תוכנה 1 תרגול 2: מערכים, לולאות והתמודדות עם שגיאות מערכים Array: A fixed-length data structure for storing multiple values of the same type Example from last week: An array of odd numbers: Indices (start

More information

IBD Intergiciels et Bases de Données

IBD Intergiciels et Bases de Données IBD Intergiciels et Bases de Données RMI-based distributed systems Fabien Gaud, Fabien.Gaud@inrialpes.fr Overview of lectures and practical work Lectures Introduction to distributed systems and middleware

More information

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions מבוא לתיכנות עם MATLAB 234127 Lecture 5: Boolean logic and Boolean expressions Written by Prof. Reuven Bar-Yehuda, Technion 2013 Based on slides of Dr. Eran Eden, Weizmann 2008 1 motivation Proper academic

More information

הנכות 1 תואיגש םע תודדומתהו תואלול,םי : כרעמ 2 לוגרת

הנכות 1 תואיגש םע תודדומתהו תואלול,םי : כרעמ 2 לוגרת תוכנה 1 תרגול 2: מערכים, לולאות והתמודדות עם שגיאות מערכים מערכים Array: A fixed-length data structure for storing multiple values of the same type Example from last week: An array of odd numbers: Indices

More information

Engineering Programming A

Engineering Programming A Engineering Programming A תרגול 5 25.11.2012 מערכים חד-מימדיים )תזכורת( לדוגמא: מערך בשם Arr בגודל 8 שאיבריו מטיפוס int 3 7 5 6 8 1 23 16 0 1 2 3 4 5 6 7 ב - arr[0] ב יושב ערך שהוא המספר השלם 3 arr[1]

More information

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes בית הספר למדעי המחשב אוניברסיטת תל אביב

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes בית הספר למדעי המחשב אוניברסיטת תל אביב תוכנה 1 תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes בית הספר למדעי המחשב אוניברסיטת תל אביב 1 2 STATIC VS. DYNAMIC BINDING 3 Static versus Dynamic Binding public class Account

More information

תוכנה 1 תרגול מספר 10: תרגיל חזרה חברת הייטק בית הספר למדעי המחשב אוניברסיטת תל אביב

תוכנה 1 תרגול מספר 10: תרגיל חזרה חברת הייטק בית הספר למדעי המחשב אוניברסיטת תל אביב 1 תוכנה 1 תרגול מספר 10: תרגיל חזרה חברת הייטק בית הספר למדעי המחשב אוניברסיטת תל אביב 1 2 חברת הייטק בתרגיל זה נתרגל מספר נושאים אותם למדנו בשיעורים האחרונים: עיצוב ובניית מודל המורכב ממחלקות לתיאור סביבה

More information

מבוא למדעי המחשב תרגול 13: עצים בינאריים

מבוא למדעי המחשב תרגול 13: עצים בינאריים מבוא למדעי המחשב תרגול 13: עצים בינאריים עצים בינאריים - הגדרה הגדרה: עץ בינארי הוא עץ ריק (בלי צמתים) או עץ המורכב משורש ושני תתי-עצים, הוא עץ בינארי. ימני ושמאלי, שכל אחד מהם תרגיל 1 עץ בינארי מסודר

More information

תוכנה 1 תרגול 2: מערכים ומבני בקרה

תוכנה 1 תרגול 2: מערכים ומבני בקרה תוכנה 1 תרגול 2: מערכים ומבני בקרה 2 Useful Eclipse Shortcuts Ctrl+1 quick fix for errors, or small refactoring suggestions Ctrl+SPACE code content assist (auto-completion) Auto completion for main create

More information

במידה ולסעיף ניתנה תשובה ובנוסף נרשם לגבי הסעיף לא יודע/ת אזי הניקוד שיינתן

במידה ולסעיף ניתנה תשובה ובנוסף נרשם לגבי הסעיף לא יודע/ת אזי הניקוד שיינתן פקולטה: מדעי הטבע מחלקה: מדעי המחשב שם הקורס: מבוא למחשבים ושפת C קוד הקורס: 2-7028510 תאריך בחינה: שאלות חזרה למבחן. חשוב: אין להסיק ששאלות אחרות לא יכולות להישאל במבחן, אין להסיק כי נושאים מסויימים בסיליבוס

More information

סכום (סדרת ערכים) אחרת - דוגמא: סכום-ספרות (num) אם < 10 num החזר 1 או אם = 0 = num החזר 0 public static int numofdigits (int num)

סכום (סדרת ערכים) אחרת - דוגמא: סכום-ספרות (num) אם < 10 num החזר 1 או אם = 0 = num החזר 0 public static int numofdigits (int num) 1 תבנית צבירה תבניות אלגוריתמיות לפעולות רקורסיביות תבנית צבירה לסדרת ערכים: סכום (סדרת ערכים) החזר את ערך הקצה + סכום (סדרת הערכים ללא ערך הקצה) דוגמא: פעולה המחזירה את סכום הספרות שבמספר שלם לא שלילי

More information

Programming for Engineers in Python

Programming for Engineers in Python Programming for Engineers in Python Lecture 9: Sorting, Searching and Time Complexity Analysis Autumn 2011-12 1 Lecture 8: Highlights Design a recursive algorithm by 1. Solving big instances using the

More information

Programming for Engineers in Python

Programming for Engineers in Python Programming for Engineers in Python Lecture 9: Sorting, Searching and Time Complexity Analysis Autumn 2011-12 1 Lecture 8: Highlights Design a recursive algorithm by 1. Solving big instances using the

More information

Info 408 Distributed Applications Programming Exercise sheet nb. 4

Info 408 Distributed Applications Programming Exercise sheet nb. 4 Lebanese University Info 408 Faculty of Science 2017-2018 Section I 1 Custom Connections Info 408 Distributed Applications Programming Exercise sheet nb. 4 When accessing a server represented by an RMI

More information

Operating Systems. Practical Session 4 Threads

Operating Systems. Practical Session 4 Threads Operating Systems Practical Session 4 Threads 1 Threads Executed within a process. Allow multiple independent executions under the same process (container). Possible states: running, ready, blocked, terminated.

More information

פתרון מוצע לבחינת מה"ט ב_שפת c מועד אביב תשע"ח, פברואר 8102 מחבר: מר שייקה בילו, מכללת אורט רחובות

פתרון מוצע לבחינת מהט ב_שפת c מועד אביב תשעח, פברואר 8102 מחבר: מר שייקה בילו, מכללת אורט רחובות פתרון מוצע לבחינת מה"ט ב_שפת c מועד אביב תשע"ח, פברואר 8102 מחבר: מר שייקה בילו, מכללת אורט רחובות שאלה מספר 1 התוכנית מגדירה חמישה משתנים שלמים: השלושה הראשונים הם שלושה מצביעים - *s *t,i. j ושלושה נוספים

More information

מבוא למדעי המחשב תרגול 10 הממשקים Iterator, Iterable Binary trees

מבוא למדעי המחשב תרגול 10 הממשקים Iterator, Iterable Binary trees מבוא למדעי המחשב 2017 תרגול 10 הממשקים Iterator, Iterable Binary trees בתרגול היום ממשקים: Iterator Filter DynamicArrayFilterIterator עצים בינאריים. תזכורת: Iterator מידע ונתונים )data( הדרושים לתכנית

More information

Exams questions examples

Exams questions examples Exams questions examples 1 Exam example 1. y - x what נק' ( לפניך הפעולה הרקורסיבית מקבלת כפרמטרים שני מספרים שלמים ו 10 )? מה יהיה הפלט כתוצאה מזימון הפעולה what public static int what(int x, int y) if(x

More information

מבוא לתכנות בשפת C. Tzachi (Isaac) Rosen

מבוא לתכנות בשפת C. Tzachi (Isaac) Rosen מבוא לתכנות בשפת C מצביעים והקצאה דינאמית כתובות של משתנים לכל משתנה כתובת של המקום שלו בזיכרון כבר ראינו: שם של מערך הוא למעשה הכתובת של התא הראשון )באינדקס 0( של המערך להזכירכם: תא של מערך הינו משתנה

More information

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A Contents Java RMI G53ACC Chris Greenhalgh Java RMI overview A Java RMI example Overview Walk-through Implementation notes Argument passing File requirements RPC issues and RMI Other problems with RMI 1

More information

JAVA RMI. Remote Method Invocation

JAVA RMI. Remote Method Invocation 1 JAVA RMI Remote Method Invocation 2 Overview Java RMI is a mechanism that allows one to invoke a method on an object that exists in another address space. The other address space could be: On the same

More information

Distributed Objects SPL/ SPL 201 / 0 1

Distributed Objects SPL/ SPL 201 / 0 1 Distributed Objects 1 distributed objects objects which reside on different machines/ network architectures, benefits, drawbacks implementation of a remote object system 2 Why go distributed? large systems

More information

שאלה 1 מהו הפלט של התוכנית הבאה:

שאלה 1 מהו הפלט של התוכנית הבאה: תרגול חזרה שאלה 1 מהו הפלט של התוכנית הבאה: public sttic int wht(int n) { int i; int sum=0; if(n == 0) return 1; for (i=0; i

More information

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2)

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2) Introduction Objective To support interoperability and portability of distributed OO applications by provision of enabling technology Object interaction vs RPC Java Remote Method Invocation (RMI) RMI Registry

More information

הקלחמ ה תמרב ת ונ וכ ת (static members ) יליזרב דהוא Java תפשב ם דקת מ תונכת ביבא ל ת תטיסרבינוא

הקלחמ ה תמרב ת ונ וכ ת (static members ) יליזרב דהוא Java תפשב ם דקת מ תונכת ביבא ל ת תטיסרבינוא ת כו נו ת ברמת ה מחלקה (static members) אוהד ברזילי תכנות מ תקד ם בשפת Java אוניברסיטת ת ל אביב static keyword שדות המוגדרים כ static מציינים כי הם מוגדרים ברמת המחלקה ולא ברמת עצם כל העצמים של אותה מחלקה

More information

Practical Session No. 14 Topological sort,amortized Analysis

Practical Session No. 14 Topological sort,amortized Analysis Practical Session No. 14 Topological sort,amortized Analysis Topological- Sort Topological sort Ordering of vertices in a directed acyclic graph (DAG) G=(V,E) such that if there is a path from v to u in

More information

תרגילים ופתרונות בשפת - C הסתעפויות

תרגילים ופתרונות בשפת - C הסתעפויות תרגילים ופתרונות בשפת - C הסתעפויות כתב וערך: שייקה בילו תרגיל - 1 כתוב תוכנית שתקבל מהמשתמש שלושה מספרים, ותציג את הגדול מביניהם על המסך. #include void main() int mis1, mis2, mis3, max; printf("please

More information

Threads Chate Patanothai

Threads Chate Patanothai Threads Chate Patanothai Objectives Knowing thread: 3W1H Create separate threads Control the execution of a thread Communicate between threads Protect shared data C. Patanothai Threads 2 What are threads?

More information

- מבחן. - 4 עבודות ב- JAVA. הגשה בזוגות דרך ה- System Submission

- מבחן. - 4 עבודות ב- JAVA. הגשה בזוגות דרך ה- System Submission 1 - מבחן. - 4 עבודות ב- JAVA 60% 40% הגשה בזוגות דרך ה- System Submission 2 UML Class Diagrams Packages Class Path JAR Files חלק ראשון: חלק שני: 3 An abstraction of software features A structure that singles

More information

היצביט ומ - ןוכית ת וי נבת

היצביט ומ - ןוכית ת וי נבת תבני ו ת תיכון Patterns) (Design תבנ יו ת תיכון - מו טיבציה בחיי היום יום אנחנו מתארים דברים תוך שימוש בתבניות חוזרות: "מכונית א' היא כמו מכונית ב', אבל יש לה 2 דלתות במקום 4" "אני רוצה ארון כמו זה, אבל

More information

ASP.Net Web API.

ASP.Net Web API. ASP.Net Web API 1 מה זה? Web API View בלבד ולא Data אותו מממש השרת והוא מחזיר לקליינט API הוא Web API הבקשה והתשובה הן בפרוטוקול Http\Https הקליינטים של Web API יכולים להיות רבים : אפשר להשתמש גם בMVC

More information

הוראות חיבור e-port בפרוטוקול Art-Net למערכות תאורה שונות

הוראות חיבור e-port בפרוטוקול Art-Net למערכות תאורה שונות 30.06.2014 הוראות חיבור e-port בפרוטוקול Art-Net למערכות תאורה שונות המסמך נכתב ונערך ע"י רונן בן-הרוש עבור חברת דנאור מערכות תיאטרון ואולפנים בע"מ. http://www.danor.com הבדיקות נעשו באולם רובינא, בתיאטרון

More information

55:182/22C:182. Distributed Application Frameworks Java RMI, CORBA, Web Services (SOAP)

55:182/22C:182. Distributed Application Frameworks Java RMI, CORBA, Web Services (SOAP) 55:182/22C:182 Distributed Application Frameworks Java RMI, CORBA, Web Services (SOAP) Broker Architecture Example Java Remote Method Invocation (RMI) Invoking a method which lies in a different address

More information

Page 1 1 מס' מחברת : מס' ת.ז. : סמסטר א' תשס"ט מועד: א' 16/02/2009 משך הבחינה: שלוש שעות אין להשתמש בחומר עזר בחינה בקורס תכנות ב- C מרצים: אלון לרנר, עופר פסטרנק מתרגלים:

More information

Distributed Systems. Distributed Object Systems 2 Java RMI. Java RMI. Example. Applet continued. Applet. slides2.pdf Sep 9,

Distributed Systems. Distributed Object Systems 2 Java RMI. Java RMI. Example. Applet continued. Applet. slides2.pdf Sep 9, Distributed Object Systems 2 Java RMI Piet van Oostrum Distributed Systems What should a distributed system provide? Illusion of one system while running on multiple systems Transparancy Issues Communication,

More information

Graph Database, think different!

Graph Database, think different! Graph Database, think different! Written by Roni Licher Winter 2014-2015 236363 - Database Systems - Technion Nodes Edges (directed or not) Properties Neo4j and Cypher 4j Graph database (Like SQL server

More information

Real Time & Embedded Linux Solutions. C++ and OOD for Embedded Systems. משך הקורס 40 שעות לימוד ותרגול בשיטת Hands-on-Training

Real Time & Embedded Linux Solutions. C++ and OOD for Embedded Systems. משך הקורס 40 שעות לימוד ותרגול בשיטת Hands-on-Training Real Time Group Real Time & Embedded Linux Solutions C++ and OOD for Embedded Systems משך הקורס 40 שעות לימוד ותרגול בשיטת Hands-on-Training 1 Real Time Group is a multi-disciplinary dynamic and innovative

More information

תכנות מתקדם בשפת C משתנים

תכנות מתקדם בשפת C משתנים תכנות מתקדם בשפת C משתנים 1 משתנים סוגי משתנים בשפת C ההבדלים בין סוגי המשתנים השונים 2 /* This program computes m to the power of n */ /* Assumptions: m is an integer; n is a positive integer */ #include

More information

תוכנה 1 * לא בהכרח בסדר הזה

תוכנה 1 * לא בהכרח בסדר הזה תוכנה 1 תרגול 7: מנשקים, פולימורפיזם ועוד * לא בהכרח בסדר הזה 2 מנשקים מנשקים מנשק )interface( הוא מבנה תחבירי ב- Java המאפשר לחסוך בקוד לקוח. מנשק מכיל כותרות של מתודות המימוש שלהן. )חתימות( ללא קוד אשר

More information

תוכנה 1 תרגול מספר 10: תרגיל חברת הייטק בית הספר למדעי המחשב אוניברסיטת תל אביב

תוכנה 1 תרגול מספר 10: תרגיל חברת הייטק בית הספר למדעי המחשב אוניברסיטת תל אביב 1 תוכנה 1 תרגול מספר 10: תרגיל חברת הייטק בית הספר למדעי המחשב אוניברסיטת תל אביב 1 2 חברת הייטק בתרגיל זה נתרגל מספר נושאים אותם למדנו בשיעורים האחרונים: עיצוב ובניית מודל המורכב ממחלקות לתיאור סביבה

More information

קורס תכנות שיעור שני: שימוש במשתנים,

קורס תכנות שיעור שני: שימוש במשתנים, קורס תכנות שיעור שני: שימוש במשתנים, בקרת זרימה, לולאות 1 נושאי השיעור היום משתנים )variables( טיפוסי משתנים בשפת C הגדרת משתנים השמה למשתנים פעולות על משתנים קליטת ערכים מהמשתמש הדפסה משתנים בקרת זרימה

More information

ד"ר אחיה אליסף מר בני לוטטי פרופ' אנדרי שרף הנדסת תוכנה סעיף א. .(random או enum ירד על סינטקס של (לא expression / anonymous classes

דר אחיה אליסף מר בני לוטטי פרופ' אנדרי שרף הנדסת תוכנה סעיף א. .(random או enum ירד על סינטקס של (לא expression / anonymous classes אוניברסיטת בן-גוריון מדור בחינות מספר נבחן: רשמו תשובותיכם בגיליון התשובות בלבד, תשובות מחוץ לגיליון לא יבדקו. שימו לב: על תשובות ריקות יינתן 20% מהניקוד! בהצלחה! תאריך הבחינה : 13.2.2017 שם המורה : ד"ר

More information

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University CS 555: DISTRIBUTED SYSTEMS [RMI] Frequently asked questions from the previous class survey Shrideep Pallickara Computer Science Colorado State University L21.1 L21.2 Topics covered in this lecture RMI

More information

Remote Method Invocation

Remote Method Invocation Remote Method Invocation A true distributed computing application interface for Java, written to provide easy access to objects existing on remote virtual machines Provide access to objects existing on

More information

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: concurrency

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: concurrency Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: concurrency Outline Java threads thread implementation sleep, interrupt, and join threads that return values Thread synchronization

More information